﻿Imports System.Data.SqlClient
Imports PhDir.DAL
Imports PhDir.Model
Imports PhDir.Repository
Imports System.Collections.Generic

Namespace Repository.User
    Public Class UpdateUser
        Implements IUpdate(Of Model.User)

        Public Function Update(oldUser As Model.User, newUser As Model.User) As Boolean _
            Implements IUpdate(Of Model.User).Update

            Dim isSuccess = False

            Using dbConnection = New DbConnection(DbContext.PhoneContext)
                dbConnection.AddParameter("@UserId", oldUser.UserId)
                dbConnection.AddParameter("@Name", newUser.UserName)
                dbConnection.CommandText = StoredProceduresName.UpdateUser
                dbConnection.CommandType = CommandType.StoredProcedure
                isSuccess = dbConnection.ExecuteNonQuery()
            End Using

            Return isSuccess

        End Function
    End Class
End Namespace
